//
//  lxPathUtility.m
//  luodansc
//
//  Created by 倫 星 on 2012/10/20.
//  Copyright (c) 2012年 方正株式会社. All rights reserved.
//

#import "lxPathUtility.h"

@implementation lxPathUtility

+ (NSString *)homePath {
	return NSHomeDirectory();
}

+ (NSString *)documentsPath {
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	return [paths objectAtIndex:0];
}

+ (NSString *)db3Path {
	NSString* path = [[self documentsPath] stringByAppendingPathComponent:@"DB"];
	return path;
}

+ (NSString *)tempPath {
	NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"];
	return path;
	//return NSTemporaryDirectory();
}


+(NSString*)getDayStringWithDate:(NSDate*)date withSeparate:(BOOL)ishave
{
	NSString* description = [date description];
	NSRange range;
	if (ishave == NO) {
		description = [description stringByReplacingOccurrencesOfString:@"-" withString:@""];
		range.location = 0; range.length = 8;
	}
	else {
		range.location = 0; range.length = 10;
	}
    
	//description = [description stringByReplacingOccurrencesOfString:@"-" withString:@""];
	
	NSString* theDate = [description substringWithRange : range];
	return theDate;
}

/*
 + (NSString *)settingPath {
 NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/Setting.plist"];
 return path;
 }
 */

+ (BOOL)createDirectoryIfNeededByPath:(NSString *)path
{
	NSString *dir = [path stringByDeletingLastPathComponent];
	if (![[NSFileManager defaultManager] fileExistsAtPath:dir]) {
		return [[NSFileManager defaultManager] createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil];
	}
	
	return YES;
}

@end
